#pragma once

#include <gui/canvas.h>

// Битмапы английских букв (7x8 пикселей)
static const uint8_t FONT_ENG_A[] = {0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00}; // A
static const uint8_t FONT_ENG_B[] = {0x1E, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x1E, 0x00}; // B
static const uint8_t FONT_ENG_C[] = {0x0E, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0E, 0x00}; // C
static const uint8_t FONT_ENG_D[] = {0x1E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1E, 0x00}; // D
static const uint8_t FONT_ENG_E[] = {0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x1F, 0x00}; // E
static const uint8_t FONT_ENG_F[] = {0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10, 0x00}; // F
static const uint8_t FONT_ENG_G[] = {0x0E, 0x11, 0x10, 0x17, 0x11, 0x11, 0x0E, 0x00}; // G
static const uint8_t FONT_ENG_H[] = {0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00}; // H
static const uint8_t FONT_ENG_I[] = {0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00}; // I
static const uint8_t FONT_ENG_J[] = {0x0F, 0x02, 0x02, 0x02, 0x12, 0x12, 0x0C, 0x00}; // J
static const uint8_t FONT_ENG_K[] = {0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11, 0x00}; // K
static const uint8_t FONT_ENG_L[] = {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00}; // L
static const uint8_t FONT_ENG_M[] = {0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11, 0x00}; // M
static const uint8_t FONT_ENG_N[] = {0x11, 0x19, 0x15, 0x13, 0x11, 0x11, 0x11, 0x00}; // N
static const uint8_t FONT_ENG_O[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00}; // O
static const uint8_t FONT_ENG_P[] = {0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10, 0x00}; // P
static const uint8_t FONT_ENG_Q[] = {0x0E, 0x11, 0x11, 0x11, 0x15, 0x12, 0x0D, 0x00}; // Q
static const uint8_t FONT_ENG_R[] = {0x1E, 0x11, 0x11, 0x1E, 0x14, 0x12, 0x11, 0x00}; // R
static const uint8_t FONT_ENG_S[] = {0x0E, 0x11, 0x10, 0x0E, 0x01, 0x11, 0x0E, 0x00}; // S
static const uint8_t FONT_ENG_T[] = {0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00}; // T
static const uint8_t FONT_ENG_U[] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00}; // U
static const uint8_t FONT_ENG_V[] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x0A, 0x04, 0x00}; // V
static const uint8_t FONT_ENG_W[] = {0x11, 0x11, 0x11, 0x15, 0x15, 0x1B, 0x11, 0x00}; // W
static const uint8_t FONT_ENG_X[] = {0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11, 0x00}; // X
static const uint8_t FONT_ENG_Y[] = {0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x04, 0x00}; // Y
static const uint8_t FONT_ENG_Z[] = {0x1F, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1F, 0x00}; // Z

// Битмапы русских букв (7x8 пикселей)
static const uint8_t FONT_RUS_A[] = {0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00}; // А (0x90)
static const uint8_t FONT_RUS_B[] = {0x1F, 0x10, 0x10, 0x1E, 0x11, 0x11, 0x1E, 0x00}; // Б (0x91)
static const uint8_t FONT_RUS_V[] = {0x1E, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x1E, 0x00}; // В (0x92)
static const uint8_t FONT_RUS_G[] = {0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00}; // Г (0x93)
static const uint8_t FONT_RUS_D[] = {0x0E, 0x0A, 0x0A, 0x0A, 0x0A, 0x1F, 0x11, 0x00}; // Д (0x94)
static const uint8_t FONT_RUS_E[] = {0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x1F, 0x00}; // Е (0x95)
static const uint8_t FONT_RUS_ZH[] = {0x15, 0x15, 0x15, 0x1F, 0x15, 0x15, 0x15, 0x00}; // Ж (0x96)
static const uint8_t FONT_RUS_Z[] = {0x1E, 0x01, 0x01, 0x0E, 0x01, 0x01, 0x1E, 0x00}; // З (0x97)
static const uint8_t FONT_RUS_I[] = {0x11, 0x13, 0x15, 0x19, 0x11, 0x11, 0x11, 0x00}; // И (0x98)
static const uint8_t FONT_RUS_IY[] = {0x11, 0x13, 0x15, 0x19, 0x11, 0x11, 0x11, 0x00}; // Й (0x99)
static const uint8_t FONT_RUS_K[] = {0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11, 0x00}; // К (0x9A)
static const uint8_t FONT_RUS_L[] = {0x0F, 0x09, 0x09, 0x09, 0x09, 0x11, 0x11, 0x00}; // Л (0x9B)
static const uint8_t FONT_RUS_M[] = {0x11, 0x1B, 0x15, 0x11, 0x11, 0x11, 0x11, 0x00}; // М (0x9C)
static const uint8_t FONT_RUS_N[] = {0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x00}; // Н (0x9D)
static const uint8_t FONT_RUS_O[] = {0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E, 0x00}; // О (0x9E)
static const uint8_t FONT_RUS_P[] = {0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00}; // П (0x9F)
static const uint8_t FONT_RUS_R[] = {0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10, 0x00}; // Р (0xA0)
static const uint8_t FONT_RUS_S[] = {0x0E, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0E, 0x00}; // С (0xA1)
static const uint8_t FONT_RUS_T[] = {0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00}; // Т (0xA2)
static const uint8_t FONT_RUS_U[] = {0x11, 0x11, 0x11, 0x0F, 0x01, 0x01, 0x0E, 0x00}; // У (0xA3)
static const uint8_t FONT_RUS_F[] = {0x04, 0x0E, 0x15, 0x15, 0x0E, 0x04, 0x04, 0x00}; // Ф (0xA4)
static const uint8_t FONT_RUS_H[] = {0x11, 0x11, 0x09, 0x07, 0x09, 0x11, 0x11, 0x00}; // Х (0xA5)
static const uint8_t FONT_RUS_TS[] = {0x11, 0x11, 0x11, 0x11, 0x11, 0x1F, 0x01, 0x00}; // Ц (0xA6)
static const uint8_t FONT_RUS_CH[] = {0x11, 0x11, 0x11, 0x0F, 0x01, 0x01, 0x01, 0x00}; // Ч (0xA7)
static const uint8_t FONT_RUS_SH[] = {0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x1F, 0x00}; // Ш (0xA8)
static const uint8_t FONT_RUS_SCH[] = {0x15, 0x15, 0x15, 0x15, 0x15, 0x1F, 0x01, 0x00}; // Щ (0xA9)
static const uint8_t FONT_RUS_TVZ[] = {0x10, 0x10, 0x1E, 0x11, 0x11, 0x11, 0x1E, 0x00}; // Ъ (0xAA)
static const uint8_t FONT_RUS_Y[] = {0x11, 0x11, 0x11, 0x13, 0x15, 0x19, 0x11, 0x00}; // Ы (0xAB)
static const uint8_t FONT_RUS_MZ[] = {0x10, 0x10, 0x1E, 0x11, 0x11, 0x11, 0x1E, 0x00}; // Ь (0xAC)
static const uint8_t FONT_RUS_EE[] = {0x1F, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x1F, 0x00}; // Э (0xAD)
static const uint8_t FONT_RUS_YU[] = {0x12, 0x15, 0x15, 0x1D, 0x15, 0x15, 0x12, 0x00}; // Ю (0xAE)
static const uint8_t FONT_RUS_YA[] = {0x0F, 0x11, 0x11, 0x0F, 0x05, 0x09, 0x11, 0x00}; // Я (0xAF)

// Битмапы цифр (7x8 пикселей)
static const uint8_t FONT_NUM_0[] = {0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E, 0x00}; // 0
static const uint8_t FONT_NUM_1[] = {0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E, 0x00}; // 1
static const uint8_t FONT_NUM_2[] = {0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F, 0x00}; // 2
static const uint8_t FONT_NUM_3[] = {0x0E, 0x11, 0x01, 0x06, 0x01, 0x11, 0x0E, 0x00}; // 3
static const uint8_t FONT_NUM_4[] = {0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02, 0x00}; // 4
static const uint8_t FONT_NUM_5[] = {0x1F, 0x10, 0x1E, 0x01, 0x01, 0x11, 0x0E, 0x00}; // 5
static const uint8_t FONT_NUM_6[] = {0x06, 0x08, 0x10, 0x1E, 0x11, 0x11, 0x0E, 0x00}; // 6
static const uint8_t FONT_NUM_7[] = {0x1F, 0x01, 0x02, 0x04, 0x08, 0x08, 0x08, 0x00}; // 7
static const uint8_t FONT_NUM_8[] = {0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E, 0x00}; // 8
static const uint8_t FONT_NUM_9[] = {0x0E, 0x11, 0x11, 0x0F, 0x01, 0x02, 0x0C, 0x00}; // 9

// Массив указателей на битмапы русских букв в порядке UTF-8 кодов
static const uint8_t* const FONT_RUS[] = {
    FONT_RUS_A,   // А (0x90)
    FONT_RUS_B,   // Б (0x91)
    FONT_RUS_V,   // В (0x92)
    FONT_RUS_G,   // Г (0x93)
    FONT_RUS_D,   // Д (0x94)
    FONT_RUS_E,   // Е (0x95)
    FONT_RUS_ZH,  // Ж (0x96)
    FONT_RUS_Z,   // З (0x97)
    FONT_RUS_I,   // И (0x98)
    FONT_RUS_IY,  // Й (0x99)
    FONT_RUS_K,   // К (0x9A)
    FONT_RUS_L,   // Л (0x9B)
    FONT_RUS_M,   // М (0x9C)
    FONT_RUS_N,   // Н (0x9D)
    FONT_RUS_O,   // О (0x9E)
    FONT_RUS_P,   // П (0x9F)
    FONT_RUS_R,   // Р (0xA0)
    FONT_RUS_S,   // С (0xA1)
    FONT_RUS_T,   // Т (0xA2)
    FONT_RUS_U,   // У (0xA3)
    FONT_RUS_F,   // Ф (0xA4)
    FONT_RUS_H,   // Х (0xA5)
    FONT_RUS_TS,  // Ц (0xA6)
    FONT_RUS_CH,  // Ч (0xA7)
    FONT_RUS_SH,  // Ш (0xA8)
    FONT_RUS_SCH, // Щ (0xA9)
    FONT_RUS_TVZ, // Ъ (0xAA)
    FONT_RUS_Y,   // Ы (0xAB)
    FONT_RUS_MZ,  // Ь (0xAC)
    FONT_RUS_EE,  // Э (0xAD)
    FONT_RUS_YU,  // Ю (0xAE)
    FONT_RUS_YA   // Я (0xAF)
};

// Битмапы маленьких английских букв (7x8 пикселей)
static const uint8_t FONT_ENG_SMALL_R[] = {0x00, 0x00, 0x0E, 0x10, 0x10, 0x10, 0x10, 0x00}; // r
static const uint8_t FONT_ENG_SMALL_U[] = {0x00, 0x00, 0x11, 0x11, 0x11, 0x13, 0x0D, 0x00}; // u
static const uint8_t FONT_ENG_SMALL_E[] = {0x00, 0x00, 0x0E, 0x11, 0x1F, 0x10, 0x0E, 0x00}; // e
static const uint8_t FONT_ENG_SMALL_N[] = {0x00, 0x00, 0x16, 0x19, 0x11, 0x11, 0x11, 0x00}; // n

// Функции для работы с текстом
uint8_t measure_text_width(const char* str);
void draw_russian_text(Canvas* canvas, uint8_t x, uint8_t y, Align horizontal, Align vertical, const char* str);
void draw_small_text(Canvas* canvas, uint8_t x, uint8_t y, Align horizontal, Align vertical, const char* str);
const uint8_t* get_number_bitmap(char c);
const uint8_t* get_small_english_char_bitmap(char c); 